'use strict';

const Controller = require('egg').Controller;
const tencentcloud = require("tencentcloud-sdk-nodejs");
class HomeController extends Controller {
  async index() {
    const { ctx } = this;
    ctx.body = '6666';
  }
  async chat(){
	  //获取用户发送的数据
	  var userdata=this.ctx.request.query.text
	  console.log(userdata)
	  //ai处理用户数据 返回处理结果
	  
	  
	  const NlpClient = tencentcloud.nlp.v20190408.Client;
	  
	  const clientConfig = {
	    credential: {
	      secretId: "填你自己申请的",
	      secretKey: "填你自己申请的",
	    },
	    region: "ap-guangzhou",
	    profile: {
	      httpProfile: {
	        endpoint: "nlp.tencentcloudapi.com",
	      },
	    },
	  };
	  
	  const client = new NlpClient(clientConfig);
	  const params = {
	      "Query":userdata 
	  };
	
	  this.ctx.body = await client.ChatBot(params)
  }
  async facebuteaful(){
	   this.ctx.body="face 666"
  }
}

module.exports = HomeController;
